﻿Public Class ClassTache
    'Tache associée à un projet
    Public Titre As String
    Public Description As String
    Private bTerminee As Boolean
    Private dDateTerminee As Date

    Public Sub New()
        Me.Titre = ""
        Me.Description = ""
        Me.bTerminee = False
        Me.dDateTerminee = Now()
    End Sub

    Public Property Terminee() As Boolean
        Get
            Return Me.bTerminee
        End Get
        Set(ByVal value As Boolean)
            Me.bTerminee = value
            Me.dDateTerminee = Now()
        End Set
    End Property

    Public ReadOnly Property DateTerminee() As String
        Get
            If Me.bTerminee Then
                Return dDateTerminee.ToShortDateString()
            Else
                Return "<nil>"
            End If
        End Get
    End Property

    Public Sub Edit()
        FormTache.TextBoxTitre.Text = Me.Titre
        FormTache.TextBoxDescription.Text = Me.Description
        FormTache.CheckBoxCompletee.Checked = Me.bTerminee
        If Me.bTerminee Then
            FormTache.LabelDateCompletee.Text = Me.DateTerminee
        Else
            FormTache.LabelDateCompletee.Text = "<nil>"
        End If
        If FormTache.ShowDialog() = DialogResult.OK Then
            Me.Titre = FormTache.TextBoxTitre.Text
            Me.Description = FormTache.TextBoxDescription.Text
            Me.Terminee = FormTache.CheckBoxCompletee.Checked
        End If
    End Sub
End Class
